//
//  Util.swift
//  feiyu444
//
//  Created by hanweiguang on 2018/9/29.
//  Copyright © 2018年 hanweiguang. All rights reserved.
//

import UIKit


/// 状态栏高度
let kStatusBarHeight: CGFloat = ((UIApplication.shared.statusBarFrame.height == 0) ? (isIphoneX ? 44.0 : 20.0) : (UIApplication.shared.statusBarFrame.height))

/// 导航栏高度
let kNavigationBarHeight: CGFloat = (kStatusBarHeight + 44.0)

/// 通话时，热点状态栏高度
let kHotPointStatusBarHeight: CGFloat = (kStatusBarHeight + 20.0)

/// 屏幕宽
let kScreenWidth = UIScreen.main.bounds.size.width

/// 屏幕高
let kScreenHeight = UIScreen.main.bounds.size.height

/// 屏幕Size
let kScreenSize = UIScreen.main.bounds.size

/// Tabbar高度
let kTabBarHeight: CGFloat = (isIphoneX ? 83.0 : 49.0)

/// 安全区域顶部高度 == 状态栏高度
let kSafeAreaTopHeight = (kStatusBarHeight)

/// 安全区域顶部位移 == IphoneX状态栏高度变化
let kSafeAreaTopMargin: CGFloat = (isIphoneX ? 24.0 : 0.0)

/// 安全区域底部间隙 == 底部进入主屏幕手势标识高度
let kSafeAreaBottomHeight: CGFloat = (isIphoneX ? 34.0 : 0.0)

/// 屏幕宽（安全区域）
let kSafeAreaWidth = (isPortrait ? kScreenWidth : (kScreenWidth - kSafeAreaBottomHeight))

/// 屏幕高（安全区域）未加上(导航栏高度)及(底部栏高度)
let kSafeAreaHeight = (kScreenHeight - kSafeAreaTopHeight - kSafeAreaBottomHeight)

/// 是否竖屏模式
let isPortrait = (UIApplication.shared.statusBarOrientation == .portrait || UIApplication.shared.statusBarOrientation == .portraitUpsideDown)

/// 是否iOS10
let laterThanIOS10 = (Float(UIDevice.current.systemVersion)! >= 10.0)

/// 是否iOS11
let laterThanIOS11 = (Float(UIDevice.current.systemVersion)! >= 11.0)

/// 屏幕缩放比例
let kScreenScale = UIScreen.main.scale

/// iPhoneX
let isIphoneX = ((kScreenWidth == 375) && (kScreenHeight == 812))


// 宽度比
let kWidthRatio = kScreenWidth / 375.0

// 高度比
let kHeightRatio = kScreenHeight / 667.0


//全局颜色


let kBlackColor = UIColor.color(hexString: "#ff1122")

let kGrayColor = UIColor.color(hexString: "#ff5511")

let kLightColor =  UIColor.color(hexString: "#0055ff")


let  kRedColor = UIColor.color(hexString: "#55ff11")

let  kLineColor = UIColor.color(hexString: "998888")



//比例适配
let kp = fabs(kScreenWidth/320)


//----------------frame
func frame_make(_ x:CGFloat,_ y:CGFloat,_ w:CGFloat,_ h:CGFloat) -> CGRect {
    return CGRect(x:x,y:y,width:w,height:h)
}
//----------------color
func color_make(_ r:CGFloat,_ g:CGFloat,_ b:CGFloat,_ a:CGFloat) ->UIColor {
    return UIColor(red:r/255.0,green:g/255.0,blue:b/255.0,alpha:a)
}
//----------------font
func font_make(_ x:CGFloat) ->UIFont {
    return kScreenWidth > 320 ? UIFont.systemFont(ofSize: x*kp) : UIFont.systemFont(ofSize: x*kp * 1.1)
}
